package com.xz.knowledgeDuplication.pattern.mediator;

/**
 * 具体中介者角色
 *
 * @author 召
 * @date 2022-03-28 21:38:03
 */
public class MediatorStructure extends Mediator{

    /**
     * 房东
     */
    private HouseOwner houseOwner;

    /**
     * 房客
     */
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    /**
     * 与双方沟通
     *
     * @param message 信息
     * @param person 抽象同事角色
     */
    @Override
    public void connect(String message, Person person) {
        if(person == this.tenant) {
            this.houseOwner.getMessage(message);
        } else {
            this.tenant.getMessage(message);
        }
    }

}
